package com.example.testlist.moduleview;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import com.example.testlist.R;
import com.example.testlist.adapter.HomeRecyclerViewLayoutAdapter;
import com.example.testlist.view.HomeBanner;
import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;

import java.util.ArrayList;

public class HomeRecyclerViewLayout extends LinearLayout {

    Context mContext;
    LRecyclerView lRecyclerView;
    HomeRecyclerViewLayoutAdapter homeRecyclerViewLayoutAdapter;
    LRecyclerViewAdapter lRecyclerViewAdapter;
    ArrayList<String> mData = null;


    public HomeRecyclerViewLayout(Context context) {
        this(context,null);
    }

    public HomeRecyclerViewLayout(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public HomeRecyclerViewLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        inflate(mContext, R.layout.home_recycler_view_layout,this);


        lRecyclerView = findViewById(R.id.lRecyclerView);
        lRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));

        mData = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            mData.add("");
        }

        homeRecyclerViewLayoutAdapter = new HomeRecyclerViewLayoutAdapter(mContext,mData);
        lRecyclerViewAdapter = new LRecyclerViewAdapter(homeRecyclerViewLayoutAdapter);

        lRecyclerViewAdapter.addHeaderView(new HomeBanner(mContext));


        lRecyclerView.setAdapter(lRecyclerViewAdapter);


    }
}
